﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using System.Reflection;
using System.Configuration;
using System.Web.Configuration;


namespace Htss.Platform.WebApi
{
    public class JsonResult:ActionResult
    {
        public JsonResult() { }
        public override void ExecuteResult(HttpContextBase context)
        {
            context.Response.ContentType = "text/json";
        }
        /// <summary>
        /// 返回JSON格式
        /// </summary>
        /// <param name="resultType"></param>
        /// <param name="resultJson"></param>
        public void Json(string resultType,System.Data.DataTable dt)
        {
            StringBuilder str = new StringBuilder();
            str.Append("{\"resultType\":");
            str.Append(resultType);
            str.Append(",");
            str.Append(Htss.Platform.Core.Json.ToJson(dt));
            str.Append("}");
            ResultObject = str.ToString();
        }
        /// <summary>
        /// 返回普通文本字符串
        /// </summary>
        /// <param name="resultType"></param>
        /// <param name="resultStr"></param>
        public void Json(string resultType, string resultStr)
        {
            StringBuilder str = new StringBuilder();
            str.Append("{\"resultType\":");
            str.Append(resultType);
            str.Append(",\"resultText\":\"");
            str.Append(resultStr);
            str.Append("\"}");
            ResultObject = str.ToString();
        }
    }
}
